package edu.uow.devdocs

class StatusService {

    def resolveCascadeIssue(Issue issue) {
		if (issue) {
			issue.status = IssueStatus.resolved.get()
			if (issue.save(flush:true)) {
				DevelopmentTask.findAllByIssue(issue).each {
					resolveCascadeDevelopmentTask(it)
				}
			}
		}
    }
	
	def resolveCascadeDevelopmentTask(DevelopmentTask developmentTask) {
		if (developmentTask) {
			developmentTask.status = DevelopmentTaskStatus.resolved.get()
			if (developmentTask.save(flush:true)) {
				DevelopmentChecklist.findAllByDevelopmentTask(developmentTask).each{
					resolveCascadeDevelopmentChecklist(it)
				}
			}
		}
	}
	
	def resolveCascadeDevelopmentChecklist(DevelopmentChecklist developmentChecklist) {
		developmentChecklist.status = DevelopmentChecklistStatus.resolved.get()
		developmentChecklist.save(flush:true)
    }
}
